﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace PatriotCreations.JpegData
{
    public class XmpReader : ImageReader
    {
        /// <summary>
        /// Constructor that Takes an ImageSource
        /// </summary>
        /// <param name="imageSource">A valid stream that represents a jpeg image.</param>
        public XmpReader(Stream imageSource) : base(imageSource)
        {
        }

        #region Common Values Overridden

        public override string City
        {
            get { return this.Meta.GetQuery("/xmp/City").ToString(); }
        }

        public override string State
        {
            get { return this.Meta.GetQuery("/xmp/State").ToString(); }
        }

        public override string Country
        {
            get { return this.Meta.GetQuery("/xmp/Country").ToString(); }
        }

        public override string Category
        {
            get { return this.Meta.GetQuery("/xmp/Category").ToString(); }
        }

        public override string AuthorsPosition
        {
            get { return this.Meta.GetQuery("/xmp/AuthorsPosition").ToString(); }
        }

        public override string Credit
        {
            get { return this.Meta.GetQuery("/xmp/Credit").ToString(); }
        }

        public override string Urgency
        {
            get { return this.Meta.GetQuery("/xmp/Urgency").ToString(); }
        }

        public override string DateCreated
        {
            get { return this.Meta.GetQuery("/xmp/DateCreated").ToString(); }
        }

        public string ImageLocation
        {
            get { return this.Meta.GetQuery("/xmp/Location").ToString(); }
        }

        public string Creator
        {
            get { return this.Meta.GetQuery("/xmp/creator/{ulong=0}").ToString(); }
        }

        public string CopyrightNotice
        {
            get { return this.Meta.GetQuery("/xmp/rights/x-default").ToString(); }
        }

        #endregion


        #region Unique to XMP

        public string Marked
        {
            get { return this.Meta.GetQuery("/xmp/Marked").ToString(); }
        }

        public string WebStatement
        {
            get { return this.Meta.GetQuery("/xmp/WebStatement").ToString(); }
        }

        public string IntellectualGenre
        {
            get { return this.Meta.GetQuery("/xmp/IntellectualGenre").ToString(); }
        }

        public string Scene
        {
            get { return this.Meta.GetQuery("/xmp/Scene/{ulong=0}").ToString(); }
        }

        public string SubjectCode
        {
            get { return this.Meta.GetQuery("/xmp/SubjectCode/{ulong=0}").ToString(); }
        }

        #endregion

        #region Creator Contact Info - Unique to XMP

        public string CreatorAddress
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiAdrExtadr").ToString(); }
        }

        public string CreatorCity
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiAdrCity").ToString(); }
        }

        public string CreatorState
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiAdrRegion").ToString(); }
        }

        public string CreatorPostalCode
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiAdrPcode").ToString(); }
        }

        public string CreatorCountry
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiAdrCtry").ToString(); }
        }

        public string CreatorWorkPhone
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiTelWork").ToString(); }
        }

        public string CreatorWorkEmail
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiEmailWork").ToString(); }
        }

        public string CreatorWorkURL
        {
            get { return this.Meta.GetQuery("/xmp/CreatorContactInfo/CiUrlWork").ToString(); }
        }

        #endregion

        #region Dispose of resources        

        ~XmpReader()
        {
            Dispose();
        }

        #endregion
    }
}
